Coding of task reward value in the dorsal raphe nucleus: The dorsal raphe nucleus and its serotonin-releasing neurons are thought to regulate motivation and reward-seeking. These neurons are known to be active during motivated behavior, but the underlying principles that govern their activity are unknown. Here we show that a group of dorsal raphe neurons encode behavioral tasks in a systematic manner, tracking progress toward upcoming rewards. We analyzed dorsal raphe neuron activity recorded while animals performed two reward-oriented saccade tasks. There was a strong correlation between the tonic activity level of a neuron during behavioral tasks and its encoding of reward-related cues and outcomes. Neurons that were tonically excited during the task predominantly carried positive reward signals. Neurons that were tonically inhibited during the task predominantly carried negative reward signals. Neurons that did not change their tonic activity levels during the task had weak reward signals with no tendency for a positive or negative direction. This form of correlated task and reward coding accounted for the majority of systematic variation in dorsal raphe response patterns in our tasks. A smaller component of neural activity reflected detection of reward delivery. Our data suggest that the dorsal raphe nucleus encodes participation in a behavioral task in terms of its future motivational outcomes. Distinct tonic and phasic anticipatory activity in lateral habenula and dopamine neurons: Dopamine has a crucial role in anticipation of motivational events. To investigate the underlying mechanisms of this process, we analyzed the activity of dopamine neurons and one of their major sources of input, neurons in the lateral habenula, while animals anticipated upcoming behavioral tasks. We found that lateral habenula and dopamine neurons anticipated tasks in two distinct manners. First, neurons encoded the timing distribution of upcoming tasks through gradual changes in their tonic activity. This tonic signal encoded rewarding tasks in preference to punishing tasks and was correlated with classic phasic coding of motivational value. Second, neurons transmitted a phasic signal marking the time when a task began. This phasic signal encoded rewarding and punishing tasks in similar manners, as though reflecting motivational salience. Our data suggest that the habenula-dopamine pathway motivates anticipation through a combination of tonic reward-related and phasic salience-related signals. Multiple timescales of memory in lateral habenula and dopamine neurons: Midbrain dopamine neurons are thought to signal predictions about future rewards based on the memory of past rewarding experience. Little is known about the source of their reward memory and the factors that control its timescale. Here we recorded from dopamine neurons, as well as one of their sources of input, the lateral habenula, while animals predicted upcoming rewards based on the past reward history. We found that lateral habenula and dopamine neurons accessed two distinct reward memories: a short-timescale memory expressed at the start of the task and a near-optimal long-timescale memory expressed when a future reward outcome was revealed. The short- and long-timescale memories were expressed in different forms of reward-oriented eye movements. Our data show that the habenula-dopamine pathway contains multiple timescales of memory and provide evidence for their role in motivated behavior.